package com.chat.core.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chat.core.dao.GroupChatReadDao;
import com.chat.core.dao.UserDao;
import com.chat.core.entity.GroupChatRead;
import com.chat.core.entity.User;
import com.chat.core.service.GroupChatReadService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 群聊记录(GroupChatRead)表服务实现类
 *
 * @author makejava
 * @since 2022-04-19 15:58:26
 */
@Service("groupChatReadService")
public class GroupChatReadServiceImpl extends ServiceImpl<GroupChatReadDao, GroupChatRead> implements GroupChatReadService {
    @Resource
    UserDao userDao;

    @Override
    public List<GroupChatRead> getList() {
        List<GroupChatRead> groupChatReads = this.getBaseMapper().selectList(null);
        return  groupChatReads.stream().peek(x->{
            User user = userDao.selectById(x.getUserId());
            x.setUser(user);
        }).collect(Collectors.toList());
    }
}
